<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
		<title>HELLO，AMAP!</title>
		<style>
			html,
			body{
				width: 100%;
				height: 100%;
				padding: 0;
				margin: 0;
			}
			#container {
				width: 100%;
				height: 100%;
			}
		</style>
	</head>
	<body>
		<div id="container"></div>
		<script type="text/javascript">
			window._AMapSecurityConfig = {
				securityJsCode: "1c5e88544f9343d57f171cda851f273f",
			};
		</script>
		<script src="https://webapi.amap.com/loader.js"></script>
		<script type="text/javascript" src='./js/citys.js'></script>
		<script type="text/javascript">
			AMapLoader.load({
					key: "1cba3a6567effb4d9d5083016ad9463f", //申请好的Web端开发者 Key，调用 load 时必填
					version: "2.0", //指定要加载的 JS API 的版本，缺省时默认为 1.4.15
				})
				.then((AMap) => {
					var map = new AMap.Map('container', {
						zoom: 4,
						center: [116.397528, 39.920222],
						showIndoorMap: false,
						viewMode: '3D',
					});

					// JSAPI 2.0 支持显示设置 zIndex, zIndex 越大约靠前，默认按顺序排列
					var style = [{
						url: 'https://webapi.amap.com/images/mass/mass0.png',
						anchor: new AMap.Pixel(6, 6),
						size: new AMap.Size(11, 11),
						zIndex: 3,
					}, {
						url: 'https://webapi.amap.com/images/mass/mass1.png',
						anchor: new AMap.Pixel(4, 4),
						size: new AMap.Size(7, 7),
						zIndex: 2,
					}, {
						url: 'https://webapi.amap.com/images/mass/mass2.png',
						anchor: new AMap.Pixel(3, 3),
						size: new AMap.Size(5, 5),
						zIndex: 1,
					}];
					var mass = new AMap.MassMarks(citys, {
					    opacity: 0.8,
					    zIndex: 111,
					    cursor: 'pointer',
					    style: style
					});
					
					var marker = new AMap.Marker({content: ' ', map: map});
					
					mass.on('mouseover', function (e) {
					
					    marker.setPosition(e.data.lnglat);
					    marker.setLabel({content: e.data.name})
					});
					
					mass.setMap(map);
				})
				.catch((e) => {
					console.error(e); //加载错误提示
				});
		</script>
	</body>
</html>